<?php
class NewFriendInviteInfoVo extends SzAbstractMySqlVo
{

    private $userId;
    private $indexId;
    private $info;
    private $dailyTime;
    private $level;

    /**
     * Initialize NewFriendInviteInfoVo.
     *
     * @param $userId
     * @param $indexId
     * @param $info
     * @param $dailyTime
     * @param $level
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return NewFriendInviteInfoVo
     */
    public function __construct($userId, $indexId, $info, $dailyTime, $level, $isInsert = false) {
        $this->userId = $userId;
        $this->indexId = $indexId;
        $this->info = is_string($info) ? json_decode($info, true) : (array)$info;
        $this->dailyTime = $dailyTime;
        $this->level = $level;

        $this->isInsert = $isInsert;
        $this->voClassName = 'NewFriendInviteInfoVo';
        $this->ormName = 'NewFriendInviteInfo';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'indexId' => $this->getIndexId(),
            'info' => ($needEncode) ? $this->getInfo() : $this->getRawInfo(),
            'dailyTime' => $this->getDailyTime(),
            'level' => $this->getLevel(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'indexId' => $this->getIndexId(),
            'info' => ($needEncode) ? $this->getInfo() : $this->getRawInfo(),
            'dailyTime' => $this->getDailyTime(),
            'level' => $this->getLevel(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getUserId(),
            $this->getIndexId(),
            $this->getInfo(),
            $this->getDailyTime(),
            $this->getLevel(),
        );
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(0, $this->userId);
        $this->userId = $val;
    }

    public function getIndexId()
    {
        return $this->indexId;
    }

    public function setIndexId($val)
    {
        $this->saveColumnStatus(1, $this->indexId);
        $this->indexId = $val;
    }

    public function getInfo()
    {
        return json_encode($this->info);
    }

    public function getRawInfo()
    {
        return $this->info;
    }

    public function setInfo($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 12800) {
            SzLogger::get()->error('[NewFriendInviteInfoVo] The length of column info exceed the limit, length / limit: ' . $encodedLength . ' / 12800');
            throw new SzException(10522, array('NewFriendInviteInfoVo', '12800', $encodedLength));
        } else if ($encodedLength > 11520) {
            SzLogger::get()->warn('[NewFriendInviteInfoVo] The length of column info exceed the warning level, length / limit: ' . $encodedLength . ' / 12800');
        }
        $this->saveColumnStatus(2, $this->info);
        $this->info = $val;
    }

    public function getDailyTime()
    {
        return $this->dailyTime;
    }

    public function setDailyTime($val)
    {
        $this->saveColumnStatus(3, $this->dailyTime);
        $this->dailyTime = $val;
    }

    public function getLevel()
    {
        return $this->level;
    }

    public function setLevel($val)
    {
        $this->saveColumnStatus(4, $this->level);
        $this->level = $val;
    }

    public function updateLevel($val)
    {
        $this->saveColumnStatus(4, $this->level);
        $this->level += $val;
    }

}
